﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.IO;

namespace Skecthial.UI.Services
{
    /// <summary>
    /// Summary description for ControlLoader
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class ControlLoader : System.Web.Services.WebService
    {

        [WebMethod]
        public string LoadControl()
        {
            Page page = new Page();
            UserControl ctl =
              (UserControl)page.LoadControl("~/Controls/DragAndDrop.ascx");

            page.Controls.Add(ctl);

            StringWriter writer = new StringWriter();
            HttpContext.Current.Server.Execute(page, writer, false);

            return writer.ToString();
        }

        [WebMethod]
        public string LoadNewPost(string Data)
        {
            int dataLength = Data.Length;

            Page page = new Page();
            UserControl ctl = (UserControl)page.LoadControl("~/Controls/NewPost.ascx");
            page.Controls.Add(ctl);
            StringWriter writer = new StringWriter();

            HttpContext.Current.Server.Execute(page, writer, false);

            return writer.ToString();
        }

        [WebMethod]
        public string LoadDragAndDrop()
        {
            Page page = new Page();
            UserControl ctl = (UserControl)page.LoadControl("~/Controls/DragAndDrop.ascx");
            page.Controls.Add(ctl);
            StringWriter writer = new StringWriter();

            HttpContext.Current.Server.Execute(page, writer, false);

            return writer.ToString();
        }

    }
}
